package com.prs.crm.action.cqunicom;

import java.io.IOException;
import java.util.Date;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;

import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.cqunicom.BusinessOrder;
import com.prs.crm.domain.cqunicom.CurrentDate;
import com.prs.crm.domain.cqunicom.HighGradeExpected;
import com.prs.crm.domain.cqunicom.LogSerch;
import com.prs.crm.domain.cqunicom.MidBusinessOrder;
import com.prs.crm.domain.cqunicom.MonitorOrder;
import com.prs.crm.domain.cqunicom.PoplarOrder;
import com.prs.crm.service.cqunicom.BusinessOrderService;
import com.prs.crm.service.cqunicom.BusinessRemindService;
import com.prs.crm.service.cqunicom.CurrentDateService;
import com.prs.crm.service.cqunicom.FilmService;
import com.prs.crm.service.cqunicom.HighGradeExpectedService;
import com.prs.crm.service.cqunicom.LogSerchService;
import com.prs.crm.service.cqunicom.MidBusinessOrderService;
import com.prs.crm.service.cqunicom.MonitorOrderService;
import com.prs.crm.service.cqunicom.MovieService;
import com.prs.crm.service.cqunicom.NewsSendContentService;
import com.prs.crm.service.cqunicom.NewsSendPersonService;
import com.prs.crm.service.cqunicom.NoteContentService;
import com.prs.crm.service.cqunicom.NoteEditorService;
import com.prs.crm.service.cqunicom.NoteInformationService;
import com.prs.crm.service.cqunicom.NoteNumberService;
import com.prs.crm.service.cqunicom.OrderConnectingService;
import com.prs.crm.service.cqunicom.OrderReconciliationService;
import com.prs.crm.service.cqunicom.OrderService;
import com.prs.crm.service.cqunicom.PieListService;
import com.prs.crm.service.cqunicom.SenderService;
import com.prs.crm.service.cqunicom.TicketerService;
import com.prs.crm.service.hr.PersonService;
import com.prs.crm.service.sys.LogService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-3-16 下午02:23:40 简单说明
 */

public class DataManagerAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private PaginationSupport pagination;

	private CurrentDate currentDate;

	private BusinessRemindService businessRemindService;

	private CurrentDateService currentDateService;

	private PoplarOrder order;

	private OrderService orderService;

	private MidBusinessOrder midBusinessOrder;

	private MidBusinessOrderService midBusinessOrderService;

	private BusinessOrder businessOrder;

	private BusinessOrderService businessOrderService;

	private MonitorOrder monitorOrder;

	private MonitorOrderService monitorOrderService;

	private LogSerch logSerch;

	private LogSerchService logSerchService;

	private HighGradeExpected highGradeExpected;

	private HighGradeExpectedService highGradeExpectedService;

	private PieListService pieListService;

	private SenderService senderService;

	private FilmService filmService;

	private MovieService movieService;

	private NewsSendContentService newsSendContentService;
	private NewsSendPersonService newsSendPersonService;
	private NoteContentService noteContentService;
	private NoteEditorService noteEditorService;
	private NoteInformationService noteInformationService;
	private NoteNumberService noteNumberService;
	private OrderConnectingService orderConnectingService;
	private OrderReconciliationService orderReconciliationService;
	
	private LogService logService;
	
	private TicketerService ticketerService;
	
	private PersonService personService;

	/**
	 * 数据清理
	 * 
	 * @return
	 */
	@Action("clearData")
	public String clearData() {

		return SUCCESS;
	}

	/**
	 * 数据备份
	 * 
	 * @return
	 */
	@Action("backupData")
	public String backupData() {

		return SUCCESS;
	}

	@Clew(results = { "success", "none" })
	@Action(value = "backupDatas", results = {
			@Result(name = "success", type = "redirect", location = "backupData"),
			@Result(name = "none", type = "redirect", location = "backupData"),
			@Result(name = "error", type = "chain", location = "backupData") })
	public String backupDatas() throws IOException {
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("进行了数据备份");
		this.getLogSerchService().save(log);
		String curDir = System.getProperty("user.dir");
		String command = "mysqldump.exe -uroot -p1 --opt tunan_db > " + curDir
				+ "/114.sql";
		Runtime.getRuntime().exec("cmd /c " + command);

		this.setPrompt("数据备份处理中,请稍等....");
		return SUCCESS;

	}

	/**
	 * 时间刷新
	 * 
	 * @return
	 */
	@Clew(results = { "success", "none" })
	@Action(value = "refreshTime", results = {
			@Result(name = "success", type = "redirect", location = "clearData"),
			@Result(name = "none", type = "redirect", location = "clearData"),
			@Result(name = "error", type = "chain", location = "clearData") })
	public String refreshTime() {
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("刷新了数据备份时间");
		this.getLogSerchService().save(log);
		CurrentDate dd = new CurrentDate();
		dd.setCurtDate(new Date());
		this.getCurrentDateService().save(dd);
		this.setPrompt("时间刷新已成功");
		return SUCCESS;

	}

	/**
	 * 数据清理
	 * 
	 * @return
	 */
	@Clew(results = { "success", "none" })
	@Action(value = "DataClears", results = {
			@Result(name = "success", type = "redirect", location = "clearData"),
			@Result(name = "none", type = "redirect", location = "clearData"),
			@Result(name = "error", type = "chain", location = "clearData") })
	public String DataClears() {
		//日志
		this.getLogService().delLog();
		//订单提醒
		this.getBusinessRemindService().delBusinessRemind();
		// 订单清理
		
		Integer s1 = this.getOrderService().delOrder();
//		System.out.println("s1:" + s1);
		Integer s2 = this.getMonitorOrderService().delMonitorOrder();
//		System.out.println("s2:" + s2);
		Integer s3 = this.getBusinessOrderService().delBusinessOrder();
//		System.out.println("s3:" + s3);
		Integer s4 = this.getHighGradeExpectedService().delHighGradeExpected();
//		System.out.println("s4:" + s4);
		Integer s5 = this.getLogSerchService().delLogSerch();
//		System.out.println("s5:" + s5);
		// 电影
		Integer s6 = this.getPieListService().delPieList();
//		System.out.println("s6:" + s6);
		Integer s7 = this.getFilmService().delFilm();
//		System.out.println("s7:" + s7);
		//person
		Integer perss=this.getPersonService().delByPerson();
//		System.out.println("perss:"+perss);
		Integer s88=this.getTicketerService().delTicketer();
//		System.out.println("s88:"+s88);
	
		Integer s8 = this.getMovieService().delMovie();
//		System.out.println("s8:" + s8);
		Integer s9 = this.getSenderService().delSender();
//		System.out.println("s9:" + s9);

		Integer s10 = this.getNoteContentService().delNoteContent();
//		System.out.println("s10:" + s10);
		Integer s11 = this.getNewsSendPersonService().delNewsSendPerson();
//		System.out.println("s11:" + s11);
		Integer s12 = this.getNoteContentService().delNoteContent();

		Integer s13 = this.getNoteEditorService().delNoteEditor();

		Integer s14 = this.getNoteInformationService().delNoteInformation();

		Integer s15 = this.getNoteNumberService().delNoteNumber();

		Integer s16 = this.getOrderConnectingService().delOrderConnecting();

		Integer s17 = this.getOrderReconciliationService()
				.delOrderReconciliation();


		LogSerch dd = new LogSerch();
		dd.setCandlePeron(AppContext.getAccountContext().getUser()
				.getUserName());
		dd.setCandleContents("进行了全部数据清理");
		this.getLogSerchService().save(dd);

		this.setPrompt("数据清理中请稍等........");
		return SUCCESS;

	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public CurrentDate getCurrentDate() {
		return currentDate;
	}

	public void setCurrentDate(CurrentDate currentDate) {
		this.currentDate = currentDate;
	}

	public CurrentDateService getCurrentDateService() {
		return currentDateService;
	}

	public void setCurrentDateService(CurrentDateService currentDateService) {
		this.currentDateService = currentDateService;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public LogSerch getLogSerch() {
		return logSerch;
	}

	public void setLogSerch(LogSerch logSerch) {
		this.logSerch = logSerch;
	}

	public LogSerchService getLogSerchService() {
		return logSerchService;
	}

	public void setLogSerchService(LogSerchService logSerchService) {
		this.logSerchService = logSerchService;
	}

	public PoplarOrder getOrder() {
		return order;
	}

	public void setOrder(PoplarOrder order) {
		this.order = order;
	}

	public OrderService getOrderService() {
		return orderService;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	public MidBusinessOrder getMidBusinessOrder() {
		return midBusinessOrder;
	}

	public void setMidBusinessOrder(MidBusinessOrder midBusinessOrder) {
		this.midBusinessOrder = midBusinessOrder;
	}

	public MidBusinessOrderService getMidBusinessOrderService() {
		return midBusinessOrderService;
	}

	public void setMidBusinessOrderService(
			MidBusinessOrderService midBusinessOrderService) {
		this.midBusinessOrderService = midBusinessOrderService;
	}

	public BusinessOrder getBusinessOrder() {
		return businessOrder;
	}

	public void setBusinessOrder(BusinessOrder businessOrder) {
		this.businessOrder = businessOrder;
	}

	public BusinessOrderService getBusinessOrderService() {
		return businessOrderService;
	}

	public void setBusinessOrderService(
			BusinessOrderService businessOrderService) {
		this.businessOrderService = businessOrderService;
	}

	public MonitorOrder getMonitorOrder() {
		return monitorOrder;
	}

	public void setMonitorOrder(MonitorOrder monitorOrder) {
		this.monitorOrder = monitorOrder;
	}

	public MonitorOrderService getMonitorOrderService() {
		return monitorOrderService;
	}

	public void setMonitorOrderService(MonitorOrderService monitorOrderService) {
		this.monitorOrderService = monitorOrderService;
	}

	public HighGradeExpected getHighGradeExpected() {
		return highGradeExpected;
	}

	public void setHighGradeExpected(HighGradeExpected highGradeExpected) {
		this.highGradeExpected = highGradeExpected;
	}

	public HighGradeExpectedService getHighGradeExpectedService() {
		return highGradeExpectedService;
	}

	public void setHighGradeExpectedService(
			HighGradeExpectedService highGradeExpectedService) {
		this.highGradeExpectedService = highGradeExpectedService;
	}

	public PieListService getPieListService() {
		return pieListService;
	}

	public void setPieListService(PieListService pieListService) {
		this.pieListService = pieListService;
	}

	public SenderService getSenderService() {
		return senderService;
	}

	public void setSenderService(SenderService senderService) {
		this.senderService = senderService;
	}

	public FilmService getFilmService() {
		return filmService;
	}

	public void setFilmService(FilmService filmService) {
		this.filmService = filmService;
	}

	public MovieService getMovieService() {
		return movieService;
	}

	public void setMovieService(MovieService movieService) {
		this.movieService = movieService;
	}

	public NewsSendContentService getNewsSendContentService() {
		return newsSendContentService;
	}

	public void setNewsSendContentService(
			NewsSendContentService newsSendContentService) {
		this.newsSendContentService = newsSendContentService;
	}

	public NewsSendPersonService getNewsSendPersonService() {
		return newsSendPersonService;
	}

	public void setNewsSendPersonService(
			NewsSendPersonService newsSendPersonService) {
		this.newsSendPersonService = newsSendPersonService;
	}

	public NoteContentService getNoteContentService() {
		return noteContentService;
	}

	public void setNoteContentService(NoteContentService noteContentService) {
		this.noteContentService = noteContentService;
	}

	public NoteEditorService getNoteEditorService() {
		return noteEditorService;
	}

	public void setNoteEditorService(NoteEditorService noteEditorService) {
		this.noteEditorService = noteEditorService;
	}

	public NoteInformationService getNoteInformationService() {
		return noteInformationService;
	}

	public void setNoteInformationService(
			NoteInformationService noteInformationService) {
		this.noteInformationService = noteInformationService;
	}

	public NoteNumberService getNoteNumberService() {
		return noteNumberService;
	}

	public void setNoteNumberService(NoteNumberService noteNumberService) {
		this.noteNumberService = noteNumberService;
	}

	public OrderConnectingService getOrderConnectingService() {
		return orderConnectingService;
	}

	public void setOrderConnectingService(
			OrderConnectingService orderConnectingService) {
		this.orderConnectingService = orderConnectingService;
	}

	public OrderReconciliationService getOrderReconciliationService() {
		return orderReconciliationService;
	}

	public void setOrderReconciliationService(
			OrderReconciliationService orderReconciliationService) {
		this.orderReconciliationService = orderReconciliationService;
	}

	public BusinessRemindService getBusinessRemindService() {
		return businessRemindService;
	}

	public void setBusinessRemindService(
			BusinessRemindService businessRemindService) {
		this.businessRemindService = businessRemindService;
	}

	public LogService getLogService() {
		return logService;
	}

	public void setLogService(LogService logService) {
		this.logService = logService;
	}

	public TicketerService getTicketerService() {
		return ticketerService;
	}

	public void setTicketerService(TicketerService ticketerService) {
		this.ticketerService = ticketerService;
	}

	public PersonService getPersonService() {
		return personService;
	}

	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}

}
